import { defineStore } from 'pinia'
import type { ICount } from '@/types/home'

export let userStore = defineStore('count', {
    state() {
        return {
            count: {
                
            },
            token: '',
            Rcount: {
                username:'',
                password:''
            },
        }
    },
    actions: {
        saveCount(count: any) {
            this.count = count
        },
        saveToken(token: string) {
            this.token = token
        },
        saveRcount(username:string,password:string){
            this.Rcount.username = username
            this.Rcount.password = password
        },
        delRcount(){
            this.Rcount.username = ''
            this.Rcount.password = ''
        },
        delCount(){
            this.token = ''
            this.count = {}
            this.Rcount.username = ''
            this.Rcount.password = ''
        }
        
    },
    getters: {
        getCount(): any {
            return this.count
        },
        getToken(): string {
            return this.token
        },
        getRcount():any{
            return this.Rcount
        }
    },
    persist: {
        enabled: true,
        strategies: [
            {
                key: 'loginCount', //设置存储的key
                storage: localStorage, //表示存储在localStorage
            },
        ],
    },
})